package appconfig

import (
	"fmt"
	"github.com/spf13/viper"
)

type AppConfig struct {
	MySQLConfig
	RedisConfig
}

type MySQLConfig struct {
	Name   string
	Pwd    string
	Head   string
	Pore   int
	DBName string
}

type RedisConfig struct {
	Head     string
	Password string
	Pore     int
}

var AppData AppConfig

func InitAppConfig() {
	viper.SetConfigFile("./appconfig/config.yaml")
	err := viper.ReadInConfig()
	if err != nil {
		fmt.Println("获取配置文件失败")
		return
	}
	viper.Unmarshal(&AppData)
	fmt.Println("获取配置文件成功")
	fmt.Println(AppData)
}
